import { JSEncrypt } from 'jsencrypt';
import { reqPublicKey } from '@/api/user';

export const encryptText = async (text: string) => {
  // 获取公钥并对密码进行加密
  const secretKey = await reqPublicKey();
  // 新建JSEncrypt对象
  const encrypt = new JSEncrypt();
  encrypt.setPublicKey(secretKey);
  const encryptPwd = encrypt.encrypt(text) as string;
  return encryptPwd;
};
